 
 use  "${data}ACS_collapsed_2008_2021.dta",replace 
  
   
	g probcond_unmar_to_mar = 100* perwt_gotmar_aftmig /(perwt_unmar )
	g prob_unmar_to_mar     = 100*  perwt_gotmar_aftmig /(inflow_unmar )
	
	g probcond_mar_unmar =100*  perwt_gotunmar_aftmig/perwt_mar 
	g prob_mar_unmar     = 100*  perwt_gotunmar_aftmig/inflow_mar 
	
	  
  
  * RETURN MIGRATION
  
************************************************************************************************************************			
*  FIGURE B.3, PANEL and PANEL B		
************************************************************************************************************************			
 

 twoway (line  return_mar  yrusa if sex=="all" , lcolor(black) )  ///
		(line  return_unmar yrusa if sex=="all" , lcolor(gs12) ) , ///	
	legend(order(1  "Married before migration"   2  "Unmarried before migration" ) region(lwidth(none)) ///
		col(1) region(lwidth(none)) ring(0) position(11)   symxsize(5pt) size( med)  ) ///
		    xtitle("Years in the US")  ytitle("")   ylab(, angle(horizontal)) graphregion(color(white)) ///
			xlabel(1 2 3 4 5 6 7 8 9) title("Figure 3, panel a") name(fig3_A,replace)
	
	graph export "${result}FigB3_panelA.eps",  replace 
		
			
 twoway (line  return_mar  yrusa  if sex=="male" ,   lcolor(black)    )  ///
		(line  return_mar  yrusa  if sex=="female" , lcolor(gs12)  )  ///
		(line  return_unmar yrusa if sex=="male" ,  lcolor(black) lpattern(longdash)   ) ///
		(line  return_unmar yrusa if sex=="female" , lcolor(gs12) lpattern(longdash)   ) , ///
	legend(order(1  "Married before migration, Male"  2 " ''  '', Female"    ///
				3  "Unmarried  before migration, Male"   4  " ''  '', Female" ) region(lwidth(none)) ///
				 col(1) region(lwidth(none)) ring(0) position(11)   symxsize(5pt) size( med) ) ///
		    xtitle("Years in the US")  ytitle("")   ylab(, angle(horizontal)) graphregion(color(white)) ///
			xlabel(1 2 3 4 5 6 7 8 9)   name(fig3_B,replace)

	graph export "${result}FigB3_panelB.eps",  replace 
			
************************************************************************************************************************			
*  FIGURE B.4, PANEL A 	
************************************************************************************************************************			
 
 twoway  (line  probcond_unmar_to_mar  yrusa  if sex=="male" ,  lcolor(black) )  ///	
		 (line  prob_unmar_to_mar     yrusa   if sex=="male" , lcolor(black)  lpattern(dash))  ///	
         (line  probcond_mar_unmar  yrusa     if sex=="male" , lcolor(gs12)  )  ///	
		 (line  prob_mar_unmar  yrusa         if sex=="male" ,lcolor(gs12)   lpattern(dash)),   ///	
		    xtitle("Years in the US")  ytitle("")   ylab(, angle(horizontal)) graphregion(color(white))  xlabel(1 2 3 4 5 6 7 8 9) ///
			legend(order(1 "Probability to get married" "conditional on staying" 2  "Unconditional probability" ///
						 3 "Probability to get unmarried" "conditional on staying" 4  "Unconditional probability" ) ///
						 col(1) region(lwidth(none)) ring(0) position(11) symxsize(5pt) size( medsmall)) ///
			 name(figB4_A,replace)			 
			
	graph export "${result}FigB4_panelA.eps",  replace 
	
 
************************************************************************************************************************			
* *  FIGURE B.4, PANEL B	
************************************************************************************************************************			
 
   twoway  (line  probcond_unmar_to_mar  yrusa  if sex=="female" , lcolor(black) )  ///	
		   (line  prob_unmar_to_mar  yrusa 	    if sex=="female" ,lcolor(black)  lpattern(dash))  ///	
           (line  probcond_mar_unmar  yrusa     if sex=="female" , lcolor(gs12) )  ///	
		   (line  prob_mar_unmar  yrusa         if sex=="female" ,lcolor(gs12) lpattern(dash)),   ///	
		    xtitle("Years in the US")  ytitle("")   ylab(, angle(horizontal)) graphregion(color(white))  xlabel(1 2 3 4 5 6 7 8 9) ///
			legend(order(1 "Probability to get married" "conditional on staying" 2  "Unconditional probability" ///
						 3 "Probability to get unmarried" "conditional on staying" 4  "Unconditional probability" ) ///
						 col(1) region(lwidth(none)) ring(0) position(11) symxsize(5pt) size( medsmall)) ///
				name(figB4_B,replace)			 
			
graph export "${result}FigB4_panelB.eps",  replace 
	
 